<template>
	<view class="resume_wap">
		<u-navbar :is-back="true" :border-bottom="false" title="简历编辑" height="46" title-color="#333" :title-bold="true"
		 :title-size="36">
		</u-navbar>
		<view class="resume_edit_box" v-for="(item,index) in list" :key="index">
			<basics :basicsData="basicsData" v-if="item.namexb=='rscbase'" />
			<education :educationData="educationData" v-if="item.namexb=='rscjyjl'" :colid="colid" />
			<work-experience v-if="item.namexb=='rscgzjl'" :workData="workData" :colid="colid" />
			<honor v-if="item.namexb=='rsczs'" :honorData="honorData" :colid="colid" />
			<evaluate v-if="item.namexb=='rsczwpj'" :evaluateData="evaluateData" :colid="colid" />
			<type-work v-if="item.namexb=='rscgzbox'" :typework="typework" :colid="colid" />
			<admin v-if="item.namexb=='rscglbox'" :adminData="adminData" :colid="colid" />
			<team v-if="item.namexb=='rsctdbox'" :teamData="teamData" :colid="colid" />
			<!-- <job-wanted v-if="item.namexb=='rscwhere'" /> -->
			<work-display v-if="item.namexb=='rscgcal'" :workdisplayData="workdisplayData" :colid="colid" />
		</view>
		<view class="resume_btn">
			<view class="resume_btn_com resume_btn_mkgl" @click="GoModular">
				<u-icon name="grid" color="#00C091" size="32" style="margin-right: 15rpx;"></u-icon>模块管理
			</view>
			<view class="resume_btn_com resume_btn_jlyl">
				<u-icon name="order" color="#fff" size="32" style="margin-right: 15rpx;"></u-icon>简历预览
			</view>
		</view>
	</view>
</template>

<script>
	import Basics from "./chidComps/Basics.vue"
	import Education from "./chidComps/Education.vue"
	import Evaluate from "./chidComps/Evaluate.vue"
	import WorkExperience from "./chidComps/WorkExperience.vue"
	import Honor from "./chidComps/Honor.vue"
	import TypeWork from "./chidComps/TypeWork.vue"
	import Admin from "./chidComps/Admin.vue"
	import Team from "./chidComps/Team.vue"
	import JobWanted from "./chidComps/JobWanted.vue"
	import WorkDisplay from "./chidComps/WorkDisplay.vue"
	export default {
		data() {
			return {
				mbbm: "",
				typework: {
					gz: '',
					bzz: '',
					jkzk: '',
					jndj: '',
					jndjzsbh: '',
					gznr: '',
					gzfw: '',
					fwbz: '',
				},
				typegz: [],
				colid: "",
				teamData: {
					tdlb: '',
					tdrs: '',
					tdnl: '',
					tdjs: '',
					tdkj: '',
				},
				adminData: {
					gljb: "",
					glzw: "",
					qwhy: "",
					zyyj: "",
				},
				adminjb: [{
					id: 6,
					name: "高管"
				}, {
					id: 7,
					name: "中层"
				}],
				name: "woman",
				resumeMyData: [],
				basicsData: {
					csrq: "",
					qq: "",
					wx: "",
					xb: "",
					xm: "",
					tx: "",
					zz: "",
					lxdh: "",
					jg: "",
					id: "",
				},
				educationData: [],
				evaluateData: '',
				workdisplayData: [],
				workData: [],
				honorData: [],
				xbData: [{
						xb: "男",
						name: "man",
						colorStyle: "margin-left: 15rpx;background-color: #7779ff;"
					},
					{
						xb: "女",
						name: "woman",
						colorStyle: "margin-left: 15rpx;background-color: #FF6464;"
					}
				],
				list: [],
				listzt: [{
						src: "../../../static/index/resume/jbxx.png",
						name: "基本信息",
						namexb: "rscbase"
					},
					{
						src: "../../../static/index/resume/jbxx.png",
						name: "自我评价",
						namexb: "rsczwpj"
					},
					{
						src: "../../../static/index/resume/jbxx.png",
						name: "工种信息",
						namexb: "rscgzbox"
					},
					{
						src: "../../../static/index/resume/jbxx.png",
						name: "管理信息",
						namexb: "rscglbox"
					},
					{
						src: "../../../static/index/resume/jbxx.png",
						name: "团队信息",
						namexb: "rsctdbox"
					},
					{
						src: "../../../static/index/resume/jbxx.png",
						name: "求职意向",
						namexb: "rscwhere"
					},
					{
						src: "../../../static/index/resume/jbxx.png",
						name: "教育背景",
						namexb: "rscjyjl"
					},
					{
						src: "../../../static/index/resume/jbxx.png",
						name: "奖项荣誉",
						namexb: "rsczs"
					},
					{
						src: "../../../static/index/resume/jbxx.png",
						name: "工作经验",
						namexb: "rscgzjl"
					},
					{
						src: "../../../static/index/resume/jbxx.png",
						name: "工程案例",
						namexb: "rscgcal"
					}
				]
			}
		},
		async onLoad(options) {
			await this.lCodedata()
			this.mbbm = options.mbbm
			await this.resumemy(options.id)
			uni.$on('refreshData', () => {
				this.resumemy(options.id) //返回后调用refreshData 内方法
			})
		},
		onReady() {
			// var ul = document.querySelector('.resume_edit_box');
			// // ul.innerHTML=``
			// console.log(ul.children)
		},
		onBackPress(e) {
			uni.$emit('resumeData');
		},
		methods: {
			async resumemy(id) {
				let _this = this
				let params = {
					ak: this.$store.state.token,
					cmd: 'lPeople_myquery',
					para: {
						"id": id,
					}
				}
				const res = await this.$u.api.resumedata(params)
				this.resumeMyData = res.Data
				if (res.Data.tx) {
					if (res.Data.tx.indexOf('http') == -1) {
						this.resumeMyData.tx = this.baseUrl + this.resumeMyData.tx
					} else {
						this.resumeMyData.tx = this.resumeMyData.tx
					}
				}
				// this.resumeMyData.grjb = this.grjb.filter(item => item.id == this.resumeMyData.grjb)
				this.basicsData.csrq = res.Data.csrq
				this.basicsData.qq = res.Data.qq
				this.basicsData.wx = res.Data.wx
				this.basicsData.xb = res.Data.xb
				this.basicsData.xb = this.xbData.filter(item => item.xb == this.basicsData.xb)
				this.basicsData.xm = res.Data.xm
				this.basicsData.tx = this.resumeMyData.tx
				this.basicsData.zz = res.Data.zz
				this.basicsData.lxdh = res.Data.lxdh
				this.basicsData.jg = res.Data.jg
				this.basicsData.id = res.Data.id
				this.colid = res.Data.id

				this.typework.gz = this.typegz.filter(item => item.id == res.Data.gz) != "" ? this.typegz.filter(item => item.id ==
					res.Data.gz)[0].name : "";
				this.typework.bzz = res.Data.bzz
				this.typework.jkzk = res.Data.jkzk
				this.typework.jndj = res.Data.jndj
				this.typework.jndjzsbh = res.Data.jndjzsbh
				this.typework.gznr = res.Data.gznr
				this.typework.gzfw = res.Data.gzfw
				this.typework.fwbz = res.Data.fwbz

				this.teamData.tdlb = this.typegz.filter(item => item.id == res.Data.tdlb) != "" ? this.typegz.filter(item => item.id ==
					res.Data.tdlb)[0].name : "";
				this.teamData.tdrs = res.Data.tdrs
				this.teamData.tdnl = res.Data.tdnl
				this.teamData.tdjs = res.Data.tdjs
				this.teamData.tdkj = res.Data.tdkj

				this.adminData.gljb = this.adminjb.filter(item => item.id == res.Data.gljb) != "" ? this.adminjb.filter(item =>
					item.id == res.Data.gljb)[0].name : "";
				this.adminData.glzw = this.typegz.filter(item => item.id == res.Data.glzw) != "" ? this.typegz.filter(item => item
					.id == res.Data.glzw)[0].name : "";
				this.adminData.qwhy = res.Data.qwhy
				this.adminData.zyyj = res.Data.zyyj

				this.educationData = res.Data.jyjl != "" ? JSON.parse(res.Data.jyjl) : []
				this.workdisplayData = res.Data.gcal != "" ? JSON.parse(res.Data.gcal) : []
				this.workData = res.Data.gzjl != "" ? JSON.parse(res.Data.gzjl) : []
				this.honorData = res.Data.zs != "" ? JSON.parse(res.Data.zs) : []

				this.evaluateData = res.Data.zwpj
				this.list=[]
				if (this.list.length == 0) {
					let config = []
					if (JSON.parse(res.Data.thmconfig).topbox) {
						config.push([...JSON.parse(res.Data.thmconfig).topbox])
					}
					if (JSON.parse(res.Data.thmconfig).bottombox) {
						config.push([...JSON.parse(res.Data.thmconfig).bottombox])
					}
					if (JSON.parse(res.Data.thmconfig).leftbox) {
						config.push([...JSON.parse(res.Data.thmconfig).leftbox])
					}
					if (JSON.parse(res.Data.thmconfig).rightbox) {
						config.push([...JSON.parse(res.Data.thmconfig).rightbox])
					}
					config = config.flat(Infinity)
					config.forEach(function(val) {
						_this.listzt.forEach(function(time) {
							if (val == time.namexb) {
								_this.list.push(time)
							}
						})
					})
					console.log(this.typework)
				}
			},

			async lCodedata() {
				let params = {
					cmd: 'lCode_list_proc',
					para: {
						"pageindex": 1,
						"pagesize": 1000
					}
				}
				const res = await this.$u.api.lCodedata(params)
				this.typegz = res.Data.Data;

			},
			GoModular() {
				this.$u.route('/pages/HomeLnner/ResumeMod/ResumeMod', {
					id: this.resumeMyData.id
				});
			}
		},
		components: {
			"basics": Basics,
			"education": Education,
			"work-experience": WorkExperience,
			"honor": Honor,
			"evaluate": Evaluate,
			"type-work": TypeWork,
			"admin": Admin,
			"team": Team,
			"job-wanted": JobWanted,
			"work-display": WorkDisplay
		}
	}
</script>

<style scoped lang="scss">
	// #ifdef H5
	page {
		background-color: #F7F7F7;
	}

	// #endif
	.resume_wap {
		padding: 0 30rpx;
		background-color: #F7F7F7;
		// height: 100vh;

		.resume_btn {
			margin-top: 50rpx;
			padding-bottom: 40rpx;
			display: flex;
			justify-content: space-between;

			.resume_btn_com {
				width: 45%;
				height: 80rpx;
				line-height: 80rpx;
				text-align: center;
				border: 2rpx solid #00C091;
				border-radius: 35px;
				font-size: 32rpx;
			}

			.resume_btn_mkgl {
				color: #00C091;
			}

			.resume_btn_jlyl {
				background-color: #00C091;
				color: #fff;
			}
		}
	}
</style>
